package com.etime.shycourse.services.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.dao.OrgTeacherMapper;
import com.etime.shycourse.dto.OrgTeacherDtoS;
import com.etime.shycourse.services.interfaces.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName : TeacherServiceImpl  //类名
 * @Description : 教师管理  //描述
 * @Author : W //作者
 * @Date: 2022/4/6  10:11
 */
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private OrgTeacherMapper mapper;

    /**
     * 教师管理 分页管理
     *
     * @param dto
     * @return Page<OrgTeacherDtoS>
     */
    @Override
    public Page<OrgTeacherDtoS> selectTeacherPage(OrgTeacherDtoS dto, Long pageNum, Long pageSize) {
        /*当前端没有传分页数据时 就使用 page默认的值
         * pagesize = 1L
         * size = 10L;
         */
        Page<OrgTeacherDtoS> page;
        if (pageNum != null & pageSize != null) {
            page = new Page<>(pageNum, pageSize);
        } else {
            page = new Page<>();
        }
        if (dto.getUsertruename() != null) {
            dto.setUsertruename('%' + dto.getUsertruename() + '%');
        }
        return mapper.selectTeacherPage(page, dto);
    }
}

